<?php

namespace app\admin\controller\invite;

use app\admin\model\UM as UM;
use app\admin\service\FixcardService;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use think\APP;
use think\Request as Request;

/**
 * Fixcard 控制器
 * Class Fixcard
 * @package app\admin\controller\invite;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 * @see \app\admin\validate\invite\Fixcard
 */
class Fixcard
{
    // 请求参数
    private Request $request;

    // service
    private FixcardService $service;

    public function __construct(Request $request, FixcardService $fixcardService)
    {
        $this->request = $request;
        $this->service = $fixcardService;
    }

    /**
     * 补充赠送获客卡
     * @param UM $user
     * @return ApiResponse
     * @url /invite/fixcard/save
     */
    public function save(UM $user): ApiResponse
    {
        $request = $this->request;

        $this->service->modify($user, $request->param('id'), $request->param());

        return ApiResponse::success(null);
    }
}
